<%@ page contentType="text/html;charset=utf-8" pageEncoding="UTF-8"%>
<%@page isELIgnored="false"%>
<%@ taglib prefix="cw" uri="/widget-tags"%>
<cw:base></cw:base>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>淳安劳动和社会保障一体化信息系统</title>
		<SCRIPT type="text/javascript">
			function onSubmit(){
				Ext.getCmp('aac040').enable();
	     		var aac001 = Ext.getCmp('aac001_cmp').getValue();
		      	if(aac001 == ''){
		      		Ext.MessageBox.alert('提示信息','请先查询出个人信息~！');
		      		return;
		      	}
									
				if(validate_form()){//客户端对于表单的验证				
					var m = Ext.getCmp('xzGrid1').getRange();
					var jsonData = "";
	        		for(var i = 0, len = m.length; i < len; i++){
						var ss = JSON.stringify(m[i].data);
						if ( i==0 ){
	           				jsonData = jsonData + ss;
			   			}else{
							jsonData = jsonData + "," + ss;
						}	
	        		}		
	        		var is_autobs = Ext.getCmp('is_autobs').getValue();
					if("is"==is_autobs){
						if(!confirm("请确认人员的补缴信息是否正确？"))return;
						}
					var cmp_form = Ext.getCmp('cmp_operateinfoform');	
					cmp_form.form.doAction('submit',{ 
			  			url:'<s:url value="/a2/f30110208/saveTransferCorpAction.action"/>', 
			  			params:{
		  					aac001: Ext.getCmp('aac001').getValue(),
		  					aab001: Ext.getCmp('aab001').getValue(),
		  					modifiedData: jsonData
			  			},
			  			timeout:36000000000,
			  			waitMsg:'单位调动业务操作保存中......', 
			  			reset: false, 
			  			success: function(cmp_form, action) { 
			    			Ext.MessageBox.alert('Message', '单位调动业务保存成功'); 
			    			Ext.getCmp('button_submit').disable();			    			  	
			  			},
			  			failure: function(cmp_form, action) { 
			    			Ext.MessageBox.alert('Message', '单位调动业务保存不成功');
			    			Wonders.utils.handleError(action.response.responseText,false,false); 		    		
			  			} 				 
					});											
				}		
			}
				
			function initStatus(){
				//document.getElementById("bs1").checked=true;
				Ext.getCmp('grid_bs').hide();
				//Ext.getCmp('query').hide();
				//afteredit();								
			}
			
			var flag=true;
			function changeIsBs(){
				if(flag){
					Ext.getCmp('grid_bs').show();
					Ext.getCmp('query').show();
					flag = false;
				}else{
					Ext.getCmp('grid_bs').hide();
					Ext.getCmp('query').hide();
					flag=true;
				}
			}
		
			function changeNoBs(){
			   var is_autobs = Ext.getCmp('is_autobs');
			   is_autobs.setValue('no');
			   Ext.getCmp('grid_bs').hide();
			   Ext.getCmp('oppanel1x').hide();
			}
		
		   function setJwbl(c,r,i){
	
				var store = Ext.getCmp('xzGrid1');	
				var grid = Ext.getCmp('grid2');
				var selectedRecord =grid.getSelectionModel().getSelected();
			  	selectedRecord.set('aaa042',r.data.aaa042);
			  	selectedRecord.set('aaa041',r.data.aaa041);
			  	selectedRecord.set('aaa052',r.data.aaa052);
				//根据征缴规则计算缴费基数	
				var aab001 = Ext.getCmp('aab001').getValue();
				var jfgz = Ext.getCmp('aac040').getValue();
				if(!(aab001==null || aab001=='') && !(jfgz==null || jfgz=='') ){
	
					var params = {
						aaz289: r.data.code,
						aae140: selectedRecord.get('aae140'),
						aab001: aab001,
						jfgz: jfgz
					};
					var url = '<s:url value="/a2/f30110201/getPsnlAllContriRadixAction.action"/>'
					var mask = new Ext.LoadMask(Ext.getCmp('cmp_operateinfoform').el, {msg:'缴费基数计算中...'});
					if(mask){
						mask.show();
					}
					Wonders.utils.request(url, params, 'post', function(response, options){
						var msg = response.responseText;
						var jfjs_temp = msg.split(':');
				    	var jfjs = jfjs_temp[1].replace('}','');
		
				    	selectedRecord.set('aaz289',r.data.code);
		            	selectedRecord.set('jfjs',jfjs);
		            
						mask.hide();	 
				      	
					});	
			 	}
		   }
	   
      //将jfjs为0替换成--
      function jfjsConvert(){
      
           return function(v){
              if(v == 0){
                 return '--';
               }
               else{
                 return v;
               }
           };
                
      }
		function change_zjgz(){
			var grid = Ext.getCmp('grid2');
			var selectedRecord =grid.getSelectionModel().getSelected();
			var aae140 = selectedRecord.get('aae140');
			if(!(aae140 == null || aae140 == '')){
				var store = Ext.getCmp('AAZ289_DIC_SIG');
			   	store.load({
		        	url:'<s:url value="a2/f30110201/listAaz289SigAction.action"/>',
					params: {aae140: aae140}
				});
            }
		}
       
		//从字典表中取出List的数据 “险种征缴方式”
		function getAae140_index(v, m , r){
			var name = "";
			var store = Ext.getCmp("AAE140_DIC");
			var m = store.getRange();
			for(var i = 0, len = m.length; i < len; i++){
		        if(m[i].data.code == v){
		        	name = m[i].data.name;			   
		        	break;
		        }else{
		        	continue;		
		        }
	        }		     
	       return name;			
		}
		
		function getAaz289_index(v, m , r){
			var name = v;
			var store = Ext.getCmp("AAZ289_DIC_ALL");
			var m = store.getRange();
            var msg = '';
			for(var i = 0, len = m.length; i < len; i++){
		        if(m[i].data.code == v){
		        	name = m[i].data.name;	  
		        	break;
		        }else{
		        	continue;		
		        }
	        }	   
	       return name;			
		}				
		
		function selectCompany(recordId,record){
			var aaz111 = Ext.getCmp('aaz111').getValue();
			//document.companyACForm.cid.value=recordId;
			Ext.getCmp('aaz137').setValue(recordId);
			if(!(recordId == null || recordId=='')){	
				//显示单位基本信息
				var form = Ext.getCmp('cmp_test');
				form.load({
					url:"json4.txt",
					params: {aab001: recordId},
					waitMsg:'载入数据中...',
					success:function(){
						
					    Ext.getCmp('aae044_cmp').setValue(Ext.getCmp('aae044_test').getValue());
						Ext.getCmp('aaz111').setValue(aaz111);
					},
					failure: function(form, action) { 
		    			Ext.getCmp('button_submit').disable();	
		    			Wonders.utils.handleError(action.response.responseText,false,false);  
					}
				});
			}
		}
       
       //取个人身份字典表
		function getAAC066(v,m,r){
		var aac066_name = "";
		var store = Ext.getCmp("AAC066_DIC");
		var m = store.getRange();
		for(var i = 0, len = m.length; i < len; i++){
	        if(m[i].data.code == v){
	        	aac066_name = m[i].data.name;
	        	break;
	        }else{
	        	continue;		
	        }
        }
        return aac066_name;
	}    
	   
	//重置个人身份
	function change_aac066(c,n,b){
	  var grid = Ext.getCmp('grid2');

	  var store = Ext.getCmp('xzGrid1');
	  var selectedRecord =grid.getSelectionModel().getSelected();
	  var index = store.indexOf(selectedRecord);
	  if(index==0){	
	  	  var count = store.getTotalCount().getStore();
		  for (var i=0;i<count;i++){
		  	var record = store.getAt(i);
		  	record.set('aac066',Ext.getCmp('aac066_grid').getValue())
		  }			    	
	  }
	}
	
	//从字典表中取出List的数据 “险种缴费状态”
		function getName(v, m , r){
			var name = "";
			var store = Ext.getCmp("BAE015_DIC");
			var m = store.getRange();
			for(var i = 0, len = m.length; i < len; i++){
		        if(m[i].data.code == v){
		        	name = m[i].data.name;			   
		        	break;
		        }else{
		        	continue;		
		        }
	        }		     
	       return name;		
		}
	
	//计算缴费基数
	function cal_jfjs(obj,new_value,old){
		
	    var store = Ext.getCmp('xzGrid1');
	    var count = store.getTotalCount();
	    var aab001 = Ext.getCmp('aab001').getValue();
	    if(count > 0){
		    var aaz289s = store.getAt(0).get('aaz289');  //征缴规则
		    var aae140s = store.getAt(0).get('aae140');  //险种
		    var jfgz = new_value;
		    //校验征缴规则是否都输入了，如果有一个没输都报错
		     var v_flag = '0';
		     for (var i=0; i<count; i++){
		        var record = store.getAt(i);
			  	if(!(record.get('aaz289') == '' || record.get('aaz289') == null)){
			  	  v_flag = '1';
		      	   }
		      	 }
	
		      	 if(v_flag == '0') {
		      	    return; 
		      	    } 	 		    
		      	 
		     for (var i=1; i<count; i++){
			  	var record = store.getAt(i);
			  	var aaz289s = aaz289s + ':' + record.get('aaz289');
			  	var aae140s = aae140s + ':' + record.get('aae140');
		      	}
	     } 	
	    if(!(aab001==null&&aab001=='') && (count > 0)){
	       var params = {
						aaz289: aaz289s,
						aae140: aae140s,
						aab001: aab001,
						jfgz: jfgz
				};
			var url = '<s:url value="/a2/f30110201/getPsnlAllContriRadixAction.action"/>'
			   var mask = new Ext.LoadMask(Ext.getCmp('cmp_operateinfoform').el, {msg:'缴费基数计算中...'});
	        	if(mask){
	        		mask.show();
	        	}
			Wonders.utils.request(url, params, 'post', function(response, options){
			var msg = response.responseText;
			var  msgs = msg.split(','); 
            var store = Ext.getCmp('xzGrid1');
			for(var i=0; i<msgs.length; i++){
			     var jfjs_temp = msgs[i].split(':');
			     var jfjs = jfjs_temp[1].replace('}','');
			    var record = store.getAt(i);
			     record.set('jfjs',jfjs);
			}
		   mask.hide();	 
	      	
		       });	
		 }      
		 

	}
	
	
	//重置参保年月
	function change_cbny(obj,new_value,old){
	  var grid = Ext.getCmp('grid2');
	  var store = Ext.getCmp('xzGrid1');
      
       var selectedRecord =grid.getSelectionModel().getSelected();
	  //alert(selectedRecord.get('aae140'));
	  var index = store.indexOf(selectedRecord);
	  selectedRecord.set('cbny',new_value);
	  
	  //如果修改第一条，自动覆盖下面
	  if(index==0){	
	  	  var count = store.getTotalCount();

		  for (var i=0;i<count;i++){
		  	var record = store.getAt(i);
		  	record.set('cbny',Ext.getCmp('cbny').getValue());
		  	
		  	date = Ext.util.Format.date(new_value, 'Y-m-d H:i:s');
            date = Date.parseDate(date, 'Y-m-d H:i:s');
            date = new Date(Date.parse(date));
            date = Ext.util.Format.date(date, 'Y-m-d');

            record.data['cbny'] = date;
		  	
		  	//var record = gridStore.getAt(i);
		  	//(record_0.get('aac066'));
		  	//record.get('aac066') = record_0.get('aac066');
		  }			    	
	  }

	}
	
	function change_hfrq(t,nv,ov){
		var records = Ext.getCmp('xzGrid1').getRange();
		var cbyy = nv.format('Y');
		 
		var dd = new Date(); 
		var yy = dd.format('Y');
		var date = new Date(yy,0,1);
		
		var zyrq = Ext.getCmp('aae030_xcb').getValue(); //转移日期
		
		var store = Ext.getCmp('xzGrid1');
		var count = store.getCount();
		for(var i=0;i<count;i++){
			var record = store.getAt(i);
			var aae140 = record.get('aae140');
			if(aae140 == '110' || aae140 == '120'){
				record.set('cbny',nv);	
				record.set('cbny_temp',nv.format('Ymd'));	
			}else{
				if(cbyy==yy){
					record.set('cbny',nv);	
					record.set('cbny_temp',nv.format('Ymd'));
					}
				else{
				record.set('cbny',date);
				record.set('cbny_temp',date.format('Ymd'));	
				}
			}

		}
		var ajc050 = nv.format('Ym');
		var aae002 =Ext.getCmp('aae002_form').getValue();
		//alert(ajc050+":"+aae002);
		if(ajc050<aae002){
			 document.getElementById("bs2").checked=true;	
			 changeIsBs();
		}
		else{
			 document.getElementById("bs1").checked=true;	
			 changeNoBs();
			}
	}	
	
	   //根据缴费基数，险种，征缴规则险种补收grid内容
	   function setBsgrid(){
	      //先清空单位险种grid
	     Ext.getCmp('bsGrid').removeAll();
	     
	     var is_autobs = Ext.getCmp('is_autobs').getValue();
	     var jfgz = Ext.getCmp('aac040').getValue();
	     //如果自动补收并且缴费基数大于0 开始计算
	    // alert(is_autobs);

	     if(is_autobs == 'is' ){
	    	     	var store = Ext.getCmp('xzGrid1');
		      		var selectedRecords = store.getRange();
									
					var count =  store.getCount();
				  	if (count > 0){    
					    for (var i=count-1; i>=0; i--){
					    	
					  	   var record = selectedRecords[i];					  	   
					  	   //如果开始年月小于截止年月并且征缴规则不为空
					  	   if(record.get('cbny') != null && record.get('cbny')!= ''){
						  	   var hfny = dateConvert2(Ext.getCmp('aae030_xcb').getValue());						  	 	
						  	   if(hfny <= record.get('jzny') && record.get('aaz289')!='' ){
						  	   	   AddItem(record, hfny);
						  	   	}
					  	   	}
					    }
					 }   	
	      }

	   }	
		
		//补收grid增加行
		function AddItem(record, new_value){
		//如果有缴费基数，计算补收金额
		var jfjs = record.get('jfjs');
		var dwbsje = 0;
		var grbsje = 0;
	    var begny = new_value;
		var endny = record.get('jzny');
		var end_ys = parseFloat(endny.substring(0,4))*12 + parseFloat(endny.substring(4,endny.length));
		var beg_ys = parseFloat(begny.substring(0,4))*12 + parseFloat(begny.substring(4,begny.length));
		
		var aaa052 = record.get('aaa052');
		//如果有缴费基数，按缴费基数计算
		if(!(jfjs == null || jfjs == '' || jfjs == 0)){
            //alert(end_ys + '_' + beg_ys);
		   
		  if(aaa052.substr(0,1) == '1'){
	         dwbsje = parseFloat((end_ys - beg_ys + 1) * parseFloat(record.get('aaa042')) ).toFixed(2);
	      }
	      else{
	         dwbsje = parseFloat(parseFloat(jfjs) * (end_ys - beg_ys + 1) * parseFloat(record.get('aaa042'))).toFixed(2);
	      }
	     //个人定额
	      if(aaa052.substr(2,1) == '1'){
	         grbsje = parseFloat((end_ys - beg_ys + 1) * parseFloat(record.get('aaa041')) ).toFixed(2);
	      }
	      else{
	         grbsje = parseFloat(parseFloat(jfjs) * (end_ys - beg_ys + 1) * parseFloat(record.get('aaa041'))).toFixed(2);
	      }
		}
		//定额方式按比例乘月数计算
		else{
		  var jfgz = Ext.getCmp('aac040').getValue();
		  
		  if(jfgz > 0){
		     //单位定额
		     if(aaa052.substr(0,1) == '1'){
		       dwbsje = parseFloat((end_ys - beg_ys + 1) * parseFloat(record.get('aaa042')) ).toFixed(2);
		     }
		     else{
		       dwbsje = parseFloat(parseFloat(jfgz) * (end_ys - beg_ys + 1) * parseFloat(record.get('aaa042'))).toFixed(2);
		     }
		     //个人定额
		     if(aaa052.substr(2,1) == '1'){
		       grbsje = parseFloat((end_ys - beg_ys + 1) * parseFloat(record.get('aaa041')) ).toFixed(2);
		     }
		     else{
		       grbsje = parseFloat(parseFloat(jfgz) * (end_ys - beg_ys + 1) * parseFloat(record.get('aaa041'))).toFixed(2);
		     }
		     		     
		  }
		}
			var newRecord = {
				aae140_bs: record.get('aae140'),
				aaz289_zw_bs: record.get('aaz289'),
				dwbl_bs: record.get('aaa042'),
				grbl_bs: record.get('aaa041'),
				bsksny: new_value,
				bsjzny: record.get('jzny'),
				dwbsje: dwbsje,
				grbsje: grbsje
			};	
			Wonders.grid.addNewRow('grid_bs', 'bsGrid', newRecord);
		}	
		
       function validate_form(){
         //转移日期不能大于当前日期
         var date = new Date();
         if(Ext.getCmp('aae030_xcb').getValue()>date){
           alert('转移日期不能大于当前日期');
           return false;
         }
         //用工形式非空
         if(Ext.getCmp('aac013_xcbbg').getValue() == '' || Ext.getCmp('aac013_xcbbg').getValue() == null){
           alert('用工形式不能为空');
           Ext.getCmp('aac013_xcbbg').focus();
           return false;
         }        
         //grid中必须有值
         var store = Ext.getCmp('xzGrid1');
		 var count = store.getTotalCount();
		 if(count <= 0){
		   alert('请先查询有效险种信息');
           return false;
		 }                       

		 //grid中参保年月必输
		for (var i=0; i<count; i++){
	  	   var record = store.getAt(i);
	  	   //alert(record.get('cbny'));
	  	   if(record.get('cbny')=='' || record.get('cbny')==null ){
	  	   	   alert('参保年月不能为空');
	  	   	   return false;
	  	   	}
	    }
	    
		 //grid中征缴规则必输
		for (var i=0; i<count; i++){
	  	   var record = store.getAt(i);
	  	   if(record.get('aaz289')=='' || record.get('aaz289')==null ){
	  	   	   alert('征缴规则不能为空');
	  	   	   return false;
	  	   	}
	    }		 
         return true;
       }
       
       function afteredit(){
       
			//补收按钮隐藏
			Ext.getCmp('oppanel1x').hide();	       
       
       	   var grid = Ext.getCmp('grid2');
	       grid.on('afteredit', function(event){
	              var selGrid = event.grid;
	              var columModel = selGrid.getColumnModel();
	              var columnId = columModel.getColumnId(event.column);
	              var selGridView = selGrid.getView();
	             // var gridMainBody = selGridView.mainBody;
	              // 重写了Date处理
	               if(columnId == 'cbny'){
	                  var record = event.record;
	                  var date = record.data['cbny'];
	                  date = Ext.util.Format.date(date, 'Y-m-d H:i:s');
	                  date = Date.parseDate(date, 'Y-m-d H:i:s');
	                  date = new Date(Date.parse(date));
	                  date = Ext.util.Format.date(date, 'Y-m-d');
	                  record.data['cbny'] = date;
	              }
	           });
	    }

       //保险绑定
		function selectChange(t,i,e){
			var grid = Ext.getCmp('grid2');
			var sm = grid.getSelectionModel();
			var store = grid.getStore();
			
			var record1 = store.query('aae140', '310').first();
			var record2 = store.query('aae140', '330').first();
			var record3 = store.query('aae140', '320').first();
			
			var arr = new Array();
			if (sm.isSelected(record2)){
				arr.push(record1);				
				sm.selectRecords(arr, true);
			}else if(sm.isSelected(record3)){
				arr.push(record1);
				arr.push(record2);				
				sm.selectRecords(arr, true);
			}
		}
		function query(){
			var	aac001 = Ext.getCmp('aac001_cmp').getValue();
			if(aac001 == ''){
				Ext.MessageBox.alert('提示', '请查询需要单位调动的人员~！');	
				return false; 				
			}
			
			var store = Ext.getCmp('xzGrid1');
			var record = store.getAt(0);	
			var count = store.getTotalCount();	
			for (var i=0; i<count; i++){
				var record = store.getAt(i);	  	   
				var date_cbny = record.get('cbny');
				date_cbny = date_cbny.format('Ym');  
      			record.set('cbny_temp',date_cbny);
			}			
			if(count == 0){
				Ext.MessageBox.alert('提示', '请查询有效的单位参保信息~！');	
				return false;				
			}	
			var m = store.getRange();	
			var jsonData = "";
        	for(var i = 0, len = m.length; i < len; i++){
				var ss = JSON.stringify(m[i].data);							
				if ( i==0 ){
           			jsonData = jsonData + ss;
		   		}else{
					jsonData = jsonData + "," + ss;
				}
        	}
        	
        	var store = Ext.getCmp('bsGrid');
        	store.removeAll();
	   	   	store.load({
				params: {
	   	   	        aab001: Ext.getCmp('aab001').getValue(),
	   	   	        oldCorpId : Ext.getCmp('aaz111').getValue(),
	   	   	        aac001: Ext.getCmp('aac001').getValue(),
					modifyData: jsonData	
				},
				callback: function(r,options,success){	
					if(r.length>0){
					var a=r[0];
					if("-1"==a.get("aab001")){
						store.removeAll();
						Ext.MessageBox.alert('提示', a.get("aae044"));}
					}
				}
			});			
		}
		
		function change_aac013(t,nv,ov){
			if(nv == '3'){
				//农村合同制（农村户口人员）
				var store = Ext.getCmp('xzGrid1');
				var count = store.getTotalCount();	  	  
				for (var i=0;i<count;i++){	
					var record = store.getAt(i);
					var aae140 = record.get('aae140');
					if(aae140 == '210'){						
						record.set('aaz289',"200000000000G001");	
						record.set('aaa042',"0.01");		
						record.set('aaa041',"0.00");
						record.set('aaa052',"0000000000");
						break;					
					}				
				}
			}
		}
		
	</script>
	</head>
	<cw:base/>
	<body>
		<!-- STEP-1  标签说明：widget 初始化  -->
		
		<table>
			<COLGROUP>
				<COL width='15%'>
			</COLGROUP>
			<tr>
				<td align="right">
					查询个人：
				</td>
				<td>
					<cw:gridSelect property="searchgrid1" onSelect="selectPerson"
						fields="['aac003','aac058','aae135','aac001']"
						url="json.txt" id="searchgridid1"
						emptyText="请输入人名关键字..." displayField="name" width="500"
						valueField="id" pageSize="10" listWidth="470" autoComplete="true">
						<cw:gridSelectColumn width="80" property="aac003" header="姓名" />
						<cw:gridSelectColumn width="100" property="aac058" header="证件类型" />
						<cw:gridSelectColumn width="100" property="aae135" header="证件号码" />
						<cw:gridSelectColumn width="120" property="aac001" header="个人编号" />
					</cw:gridSelect>
				</td>
			</tr>
		</table>

		<div id="cmp_info" style="height: 200">
			<!--B1 基本信息区  -->
			<%@include file="baseinfo-cw.jsp"%>
			<cw:text property="aac001" type="hidden"></cw:text>
			<!--B2 操作信息区 -->
			<%@include file="operateinfo-cw.jsp"%>
		</div>
		<!-- STEP-END 1 引入本地样式 -->
		<link href="<s:url value='/resource/css/cayth-ext-all.css'/>"
			rel="stylesheet" type="text/css" />

		<!-- STEP-END 2 引入信息查询区 -->
		<script>
			//类似于init
			Ext.onReady(function(){
				initStatus();
			})
		
			function selectPerson(recordId,record){
				//document.personACForm.pid.value=recordId;
				// 调基本信息
				var form = Ext.getCmp('cmp_baseinfoform');
				form.form.reset();
				form.load({
					url:'json1.txt',
					params: {aac001: recordId},
					waitMsg:'载入数据中...',
					success:function(form, action){
						getPsnlInfo(recordId);	
					},
					failure: function(form, action) {
						
					}
				});
			}

        	function getPsnlInfo(recordId){
				 var form = Ext.getCmp('cmp_operateinfoform');
			    	form.load({
					url:"json6.txt",
					params: {aac001: recordId},
					waitMsg:'载入数据中...',
					success:function(){
						//Ext.getCmp('aac001').setValue(recordId);
					    var aab001 = Ext.getCmp('aab001').getValue();
					    Ext.getCmp('aaz111').setValue(aab001);
					    
					    Ext.getCmp('aaz137').setValue(aab001);
					  	var date = new Date().format('Y-m-d');
					  	Ext.getCmp('aae030_xcb').setValue(date);					  	
						loadGrid(recordId);
					},
					failure: function(form, action) {
						Ext.getCmp('button_submit').disable();	
		    			Wonders.utils.handleError(action.response.responseText,false,false);  
		    		}
				});
			}
		
			function loadGrid(recordId){
				var store = Ext.getCmp('oldBankAccount_grid').getStore();	
				store.url="json2.txt";		
				store.removeAll();		
				store.load({
					params: {aac001: recordId},
					waitMsg:'载入数据中...',
					callback:function (r,options,success){
						if(success){
							if(r.length>0){
								var aab001=r[0].get("aab001");
								if(aab001=='-1'){
									Ext.Msg.alert('提示',r[0].get("aac066"));
									return;
									}
								loadCompany();
	 							Ext.getCmp('button_submit').enable();
								}
							
						}
						
					}  			
				});	
			}
			
			function loadCompany(){
				var store = Ext.getCmp('oldBankAccount_grid').getStore();
				var count = store.getTotalCount();
				for (var i=0;i<count;i++){
					var record = store.getAt(i); 
					var aab001 = record.get('aab001');						  					
					Ext.getCmp('aab001_before').setValue(aab001);
					break;
				}
				 	
				//载入单位信息
				if(Ext.getCmp('aab001_before').getValue()!=""){		 			 	
					var cmp_form = Ext.getCmp('cmp_test');	 
					cmp_form.load({
						url:"json7.txt",
						params: {
							aab001:Ext.getCmp('aab001_before').getValue()
						},
						waitMsg:'载入数据中...',
						success:function(cmp_form, action){
							Ext.getCmp('aae044_before').setValue(Ext.getCmp('aae044_test').getValue());
						},
						failure: function(form, action) {
							Ext.getCmp('button_submit').disable();	
			    			Wonders.utils.handleError(action.response.responseText,false,false);  
			    		}								
					});
				}
			}
		</script>
	</body>
</html>
